﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace SuperManagement
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private DispatcherTimer dispatcherTimer = new DispatcherTimer();
        private DispatcherTimer dispatcherTimer1 = new DispatcherTimer();
        private DispatcherTimer GetSystemTime = new DispatcherTimer();
        public MainWindow()
        {
            InitializeComponent();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 5);
            GetSystemTime = new System.Windows.Threading.DispatcherTimer();
            GetSystemTime.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间
            GetSystemTime.Interval = new TimeSpan(0, 0, 0, 1, 0);
            GetSystemTime.Start();
            dispatcherTimer.Start();
        }

        private void ShowCurTimer(object sender, EventArgs e)
        {
            this.SystemTime.Text = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"));
            this.SystemTime.Text += " ";
            this.SystemTime.Text += DateTime.Now.ToString("yyyy年MM月dd日");   //yyyy年MM月dd日
            this.SystemTime.Text += " ";
            this.SystemTime.Text += DateTime.Now.ToString("HH:mm:ss");
        }

        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            DoubleAnimation daV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(1)));
            this.FirstShow.BeginAnimation(UIElement.OpacityProperty, daV);
            dispatcherTimer1.Tick += new EventHandler(dispatcherTimer_Tick1);
            dispatcherTimer1.Interval = new TimeSpan(0, 0, 2);
            dispatcherTimer1.Start();
            dispatcherTimer.Stop();
        }

        private void dispatcherTimer_Tick1(object sender, EventArgs e)
        {
            this.FirstShow.Visibility = Visibility.Collapsed;
            dispatcherTimer1.Stop();
        }

        private void MinWindowsFunction(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void CloseWindowFunction(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        private void E1HeightForLong(object sender, RoutedEventArgs e)
        {
            FExpander.Height = 96;
            SExpander.Height = 33;
            SExpander.IsExpanded = false;
            TExpander.Height = 33;
            TExpander.IsExpanded = false;
        }

        private void E1HeightForShort(object sender, RoutedEventArgs e)
        {
            FExpander.Height = 33;
        }

        private void E2HeightForLong(object sender, RoutedEventArgs e)
        {
            SExpander.Height = 175;
            FExpander.IsExpanded = false;
            FExpander.Height = 33;
            TExpander.IsExpanded = false;
            TExpander.Height = 33;
        }

        private void E2HeightForShort(object sender, RoutedEventArgs e)
        {
            SExpander.Height = 33;
        }

        private void E3HeightForLong(object sender, RoutedEventArgs e)
        {
            FExpander.Height = 33;
            FExpander.IsExpanded = false;
            SExpander.Height = 33;
            SExpander.IsExpanded = false;
            TExpander.Height = 96;
        }

        private void E3HeightForShort(object sender, RoutedEventArgs e)
        {
            TExpander.Height = 33;
        }

        private void LoadPage(object sender, RoutedEventArgs e)
        {
            Button item = e.Source as Button;
            FunctionShow.Text = item.Content.ToString();
            if (item != null)
            {
                DataShowFrame.Source = new Uri(item.Tag.ToString(), UriKind.Relative);
            }
        }
    }
}
